package Three;

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		ArrayIntegerStack s = new ArrayIntegerStack(n);
		int m = scan.nextInt();
		for (int i = 0; i < m; i++) {
			System.out.println(s.push(scan.nextInt()));
		}
		System.out.println(s.peek() + "," + s.empty() + "," + s.size());
		System.out.println(Arrays.toString(s.values));
		int x = scan.nextInt();
		for (int i = 0; i < x; i++) {
			System.out.println(s.pop());
		}
		System.out.println(s.peek() + "," + s.empty() + "," + s.size());
		System.out.println(Arrays.toString(s.values));
		scan.close();

	}

}
